package com.yvon.maple.cloud.web.data;

import com.yvon.boot.common.result.IErrorCode;
import com.yvon.boot.common.result.ResponseData;
import com.yvon.boot.common.result.ResultCode;

/**
 * @author : Yvon
 * @since : 2021-09-24
 */
public abstract class ApiController {

    public <T> ResponseData<T> success(T data) {
        return ResponseData.success(data);
    }

    public <T> ResponseData<T> fail(String msg) {
        return ResponseData.failed(msg);
    }

    public <T> ResponseData<T> fail(IErrorCode iErrorCode) {
        return ResponseData.failed(iErrorCode);
    }

    public ResponseData result(boolean retBool) {
        return retBool ? this.success(null) : this.fail(ResultCode.FAILED);
    }
}
